package com.cabinet.db;

import com.cabinet.Device;

import javax.xml.bind.annotation.XmlAttribute;

/**
 * Created by IntelliJ IDEA.
 * User: denny
 * Date: 10/1/13
 * Time: 6:48 PM
 * To change this template use File | Settings | File Templates.
 */
public class DBDeviceState {
  long devId;
  long conferenceId = OFF_CONFERENCE;
  boolean speak;
  boolean listen;
  boolean selfTest;

  public static final long TEACHERS_CONFERENCE = 8;
  public static final long OFF_CONFERENCE = -1;

  @XmlAttribute(name = "devId")
  public long getDevId() {
    return devId;
  }

  public String headImage(){
    if( devId<16 ){
      if( !speak && !listen ) return "Y_of.png";
      if( !speak && listen ) return "Y_tl.png";
      if( speak && !listen ) return "Y_mk.png";
      if( speak && listen ) return "Y_ol.png";
      throw new IllegalStateException();
    }
    if( devId == Device.TEACHER ){
      if( !speak && !listen ) return "T_of.png";
      if( !speak && listen ) return "T_tl.png";
      if( speak && !listen ) return "T_mk.png";
      if( speak && listen ) return "T_ol.png";
      throw new IllegalStateException();
    }

    if( !speak && !listen ) return "A_of.png";
    if( !speak && listen ) return "A_re.png";
    if( speak && !listen ) return "A_pl.png";
    if( speak && listen ) return "A_of.png";
    throw new IllegalStateException();
  }

  public void setDevId(long devId) {
    this.devId = devId;
  }

  @XmlAttribute(name = "conferenceId")
  public long getConferenceId() {
    return conferenceId;
  }

  public boolean canSwitchListen(){
    return ! isSelfTest() || isSpeak();
  }

  public void setConferenceId(long conferenceId) {
    this.conferenceId = conferenceId;
  }

  @XmlAttribute(name = "speak")
  public boolean isSpeak() {
    return speak;
  }

  public void setSpeak(boolean speak) {
    this.speak = speak;
  }

  @XmlAttribute(name = "listen")
  public boolean isListen() {
    return listen;
  }

  public void setListen(boolean listen) {
    this.listen = listen;
  }

  @XmlAttribute(name = "selfTest")
  public boolean isSelfTest() {
    return selfTest;
  }

  public void setSelfTest(boolean selfTest) {
    this.selfTest = selfTest;
  }
}
